﻿<Page
    x:Class="CoachingOrganizer.WinPhone.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:CoachingOrganizer.WinPhone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:conv="using:CoachingOrganizer.WinPhone.Converters"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.Resources>
        <conv:BoolVisibilityConverter x:Key="boolVisibilityConverter"/>
    </Page.Resources>
    <Grid>
        <ListView ItemsSource="{Binding Periods}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <DatePicker Date="{Binding StartDate}"/>
                        <DatePicker Grid.Column="1" Date="{Binding FinishDate}"/>
                        <StackPanel Grid.Column="2">
                            <Button x:Uid="Save" Command="{Binding SaveCommand}"/>
                            <Button x:Uid="Remove" Command="{Binding RemoveCommand}"/>
                            <Button x:Uid="Details" Command="{Binding GoDetailsCommand}"/>
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        <ProgressRing Width="30" Height="30" HorizontalAlignment="Center" VerticalAlignment="Center" IsActive="{Binding IsLoading}" Visibility="{Binding IsLoading, Converter={StaticResource boolVisibilityConverter}, TargetNullValue=Collapsed}"/>
    </Grid>
    <Page.BottomAppBar>
        <CommandBar>
            <AppBarButton Command="{Binding GoBackCommand}"/>
            <AppBarButton x:Uid="AddPeriod" Command="{Binding AddNewPeriodCommand}"/>
        </CommandBar>
    </Page.BottomAppBar>
</Page>
